/**
 * 
 */
package org.apache.struts2.gtgrid.views.jsp.ui;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts2.components.Component;
import org.apache.struts2.gtgrid.components.GtGrid;
import org.apache.struts2.views.jsp.ui.AbstractUITag;

import com.opensymphony.xwork2.util.ValueStack;

/**
 * 
 * 
 * @author Stevie
 * @since 2009-12-1
 * @version 1.0
 * 
 */
public class GtGridTag extends AbstractUITag {
	/**
	 * 
	 */
	private static final long serialVersionUID = 750841060355048704L;

	protected String id; // 列表id
	protected String width; // 列表宽度 支持%
	protected String height; // 列表高度 支持%
	protected String container; // 列表的容器的id.
								// 列表最后是要显示在页面中某个位置.这个容器就是那个"位置",通常是一个div或者时td.
	protected String replaceContainer; // 是否用列表代替容器元素
	protected String customHead; // 自定义表头对应的table的id或对象,或table的HTML代码
	protected String columns; // 列定义
	protected String dataset; // 列表对应的数据集
	protected String loadURL; // 读取数据的url
	protected String saveURL; // 提交数据的url
	protected String language; // 默认语言
	protected String skin; // 默认皮肤
	protected String toolbarPosition; // 工具栏的位置. 可选值:'top'/'bottom'/null,
										// 暂时不支持上下都显示.
	protected String toolbarContent; // 工具栏上要显示的东西. state表示的数据数量信息(分页信息),如共几条
										// 共几页 当前是第几条等等..toolbarContent 默认=
										// "nav | goto | pagesize | reload | add del save | print | filter chart | state"
										// ,
	protected String resizable; // 是否可手动改变整个列表区域的大小( 默认: false)
	protected String minWidth; // 可手动改变大小时,最小宽度
	protected String minHeight; // 可手动改变大小时,最小高度
	protected String showIndexColumn; // 是否显示索引列
	protected String stripeRows; // 是否交替显示行颜色
	protected String lightOverRow; // 是否开启行的鼠标悬停指示
	protected String defaultRecord; // 默认的记录样板,新增记录时,将按此样板新增.
	protected String transparentMask; // 是否显示全透明的遮罩 (默认: false )
	protected String clickStartEdit; // 是否为"点击单元格直接进入编辑状态"
	protected String reloadAfterSave; // 提交数据后是否自动刷新列表
	protected String recountAfterSave; // 提交数据后是否清空总记录数(以便后台重新统计总记录数)
	protected String showGridMenu; // 是否开启主菜单
	protected String allowCustomSkin; // 是否开启主菜单上的皮肤选择选项
	protected String allowFreeze; // 是否开启主菜单上的冻结列选项
	protected String allowHide; // 是否开启主菜单上的隐藏列选项
	protected String allowGroup; // 是否开启主菜单上的列编组选项
	protected String selectRowByCheck; // false
	protected String submitUpdatedFields; // false
	protected String pageSize; // 每页记录数
	protected String pageSizeList; // [ 25, 50, 100, 200 ]
	protected String remotePaging; // true/false 时候使用远程分页. 如果是客户端分页 要设置成 false,
									// 如果是服务的分页 要写成true.

	protected String onClickCellTopics; // 在选中某单元格时调用,返回false,则中止选中行为
	protected String onDblClickCellTopics; // 双击单元格时调用
	protected String onClickHeadTopics; // 点击列表头
	protected String onCompleteTopics; // 列表生成后调用
	protected String onShowTopics; // 列表由隐藏状态到显示状态时调用(需要开发人员手动调用,且必须调用)
	protected String onResizeTopics; // 列表大小发生变化时调用
	protected String onMouseMoveTopics; // 鼠标在列表数据区移动时调用的函数
	protected String beforeSelectRowTopics; // 在选中某行前调用,返回false,则中止选中行为
	protected String afterSelectRowTopics; // 选中某行之后调用
	protected String beforeEditTopics; // 编辑单元格前调用(虽然无参数,但是可与 activeCell
	// activeRecord交互)
	protected String afterEditTopics; // 编辑单元格前调用(虽然无参数,但是可与 activeCell
	// activeRecord交互)
	protected String beforeSaveTopics; // 保存数据前前调用 返回false,则中止save
	// 参数为提交的所有参数组成的json对象,结构后面说明
	protected String beforeLoadTopics; // 读取数据前调用 返回false,则中止load
	// 参数为提交的所有参数组成的json对象,结构后面说明
	protected String beforeInsertTopics; // 添加数据前调用 返回false,则中止insert 参数为新增的记录
	protected String afterInsertTopics; // 添加数据后调用
	protected String beforeUpdateTopics; // 修改数据前调用 返回false,则中止update
	// 参数为编辑的记录,编辑的字段,新值
	protected String afterUpdateTopics; // 修改数据后调用
	protected String beforeDeleteTopics; // 删除数据前调用 返回false,则中止del 参数为删除的记录
	protected String afterDeleteTopics; // 删除数据后调用
	protected String onUpdateRecordTopics; // 在记录发生改变时调用
	protected String beforeGotoPageTopics; // 翻页

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * org.apache.struts2.views.jsp.ComponentTagSupport#getBean(com.opensymphony
	 * .xwork2.util.ValueStack, javax.servlet.http.HttpServletRequest,
	 * javax.servlet.http.HttpServletResponse)
	 */
	@Override
	public Component getBean(ValueStack stack, HttpServletRequest req,
			HttpServletResponse res) {
		return new GtGrid(stack, req, res);
	}

	protected void populateParams() {
		super.populateParams();
		final GtGrid grid = (GtGrid) component;
		grid.setId(id);
		grid.setWidth(width);
		grid.setHeight(height);
		grid.setContainer(container);
		grid.setReplaceContainer(replaceContainer);
		grid.setCustomHead(customHead);
		grid.setColumns(columns);
		grid.setDataset(dataset);
		grid.setLoadURL(loadURL);
		grid.setSaveURL(saveURL);
		grid.setLanguage(language);
		grid.setSkin(skin);
		grid.setToolbarPosition(toolbarPosition);
		grid.setToolbarContent(toolbarContent);
		grid.setResizable(resizable);
		grid.setMinWidth(minWidth);
		grid.setMinHeight(minHeight);
		grid.setShowIndexColumn(showIndexColumn);
		grid.setStripeRows(stripeRows);
		grid.setLightOverRow(lightOverRow);
		grid.setDefaultRecord(defaultRecord);
		grid.setTransparentMask(transparentMask);
		grid.setClickStartEdit(clickStartEdit);
		grid.setReloadAfterSave(reloadAfterSave);
		grid.setRecountAfterSave(recountAfterSave);
		grid.setShowIndexColumn(showIndexColumn);
		grid.setAllowCustomSkin(allowCustomSkin);
		grid.setAllowFreeze(allowFreeze);
		grid.setAllowGroup(allowGroup);
		grid.setAllowHide(allowHide);
		grid.setSelectRowByCheck(selectRowByCheck);
		grid.setSubmitUpdatedFields(submitUpdatedFields);
		grid.setPageSize(pageSize);
		grid.setPageSizeList(pageSizeList);
		grid.setRemotePaging(remotePaging);
		
		grid.setOnClickCellTopics(onClickCellTopics);
		grid.setOnDblClickCellTopics(onDblClickCellTopics);
		grid.setOnClickHeadTopics(onClickHeadTopics);
		grid.setOnCompleteTopics(onCompleteTopics);
		grid.setOnShowTopics(onShowTopics);
		grid.setOnResizeTopics(onResizeTopics);
		grid.setOnMouseMoveTopics(onMouseMoveTopics);
		grid.setBeforeSelectRowTopics(beforeSelectRowTopics);
		grid.setAfterSelectRowTopics(afterSelectRowTopics);
		grid.setBeforeEditTopics(beforeEditTopics);
		grid.setAfterEditTopics(afterEditTopics);
		grid.setBeforeSaveTopics(beforeSaveTopics);
		grid.setBeforeLoadTopics(beforeLoadTopics);
		grid.setBeforeInsertTopics(beforeInsertTopics);
		grid.setAfterInsertTopics(afterInsertTopics);
		grid.setBeforeUpdateTopics(beforeUpdateTopics);
		grid.setAfterUpdateTopics(afterUpdateTopics);
		grid.setBeforeDeleteTopics(beforeDeleteTopics);
		grid.setAfterDeleteTopics(afterDeleteTopics);
		grid.setOnUpdateRecordTopics(onUpdateRecordTopics);
		grid.setBeforeGotoPageTopics(beforeGotoPageTopics);
	}

	public void setId(String id) {
		this.id = id;
	}

	public void setWidth(String width) {
		this.width = width;
	}

	public void setHeight(String height) {
		this.height = height;
	}

	public void setContainer(String container) {
		this.container = container;
	}

	public void setReplaceContainer(String replaceContainer) {
		this.replaceContainer = replaceContainer;
	}

	public void setCustomHead(String customHead) {
		this.customHead = customHead;
	}

	public void setColumns(String columns) {
		this.columns = columns;
	}

	public void setDataset(String dataset) {
		this.dataset = dataset;
	}

	public void setLoadURL(String loadURL) {
		this.loadURL = loadURL;
	}

	public void setSaveURL(String saveURL) {
		this.saveURL = saveURL;
	}

	public void setLanguage(String language) {
		this.language = language;
	}

	public void setSkin(String skin) {
		this.skin = skin;
	}

	public void setToolbarPosition(String toolbarPosition) {
		this.toolbarPosition = toolbarPosition;
	}

	public void setToolbarContent(String toolbarContent) {
		this.toolbarContent = toolbarContent;
	}

	public void setResizable(String resizable) {
		this.resizable = resizable;
	}

	public void setMinWidth(String minWidth) {
		this.minWidth = minWidth;
	}

	public void setMinHeight(String minHeight) {
		this.minHeight = minHeight;
	}

	public void setShowIndexColumn(String showIndexColumn) {
		this.showIndexColumn = showIndexColumn;
	}

	public void setStripeRows(String stripeRows) {
		this.stripeRows = stripeRows;
	}

	public void setLightOverRow(String lightOverRow) {
		this.lightOverRow = lightOverRow;
	}

	public void setDefaultRecord(String defaultRecord) {
		this.defaultRecord = defaultRecord;
	}

	public void setTransparentMask(String transparentMask) {
		this.transparentMask = transparentMask;
	}

	public void setClickStartEdit(String clickStartEdit) {
		this.clickStartEdit = clickStartEdit;
	}

	public void setReloadAfterSave(String reloadAfterSave) {
		this.reloadAfterSave = reloadAfterSave;
	}

	public void setRecountAfterSave(String recountAfterSave) {
		this.recountAfterSave = recountAfterSave;
	}

	public void setShowGridMenu(String showGridMenu) {
		this.showGridMenu = showGridMenu;
	}

	public void setAllowCustomSkin(String allowCustomSkin) {
		this.allowCustomSkin = allowCustomSkin;
	}

	public void setAllowFreeze(String allowFreeze) {
		this.allowFreeze = allowFreeze;
	}

	public void setAllowHide(String allowHide) {
		this.allowHide = allowHide;
	}

	public void setAllowGroup(String allowGroup) {
		this.allowGroup = allowGroup;
	}

	public void setSelectRowByCheck(String selectRowByCheck) {
		this.selectRowByCheck = selectRowByCheck;
	}

	public void setSubmitUpdatedFields(String submitUpdatedFields) {
		this.submitUpdatedFields = submitUpdatedFields;
	}

	public void setPageSize(String pageSize) {
		this.pageSize = pageSize;
	}

	public void setPageSizeList(String pageSizeList) {
		this.pageSizeList = pageSizeList;
	}

	public void setRemotePaging(String remotePaging) {
		this.remotePaging = remotePaging;
	}

	public void setOnClickCellTopics(String onClickCellTopics) {
		this.onClickCellTopics = onClickCellTopics;
	}

	public void setOnDblClickCellTopics(String onDblClickCellTopics) {
		this.onDblClickCellTopics = onDblClickCellTopics;
	}

	public void setOnClickHeadTopics(String onClickHeadTopics) {
		this.onClickHeadTopics = onClickHeadTopics;
	}

	public void setOnCompleteTopics(String onCompleteTopics) {
		this.onCompleteTopics = onCompleteTopics;
	}

	public void setOnShowTopics(String onShowTopics) {
		this.onShowTopics = onShowTopics;
	}

	public void setOnResizeTopics(String onResizeTopics) {
		this.onResizeTopics = onResizeTopics;
	}

	public void setOnMouseMoveTopics(String onMouseMoveTopics) {
		this.onMouseMoveTopics = onMouseMoveTopics;
	}

	public void setBeforeSelectRowTopics(String beforeSelectRowTopics) {
		this.beforeSelectRowTopics = beforeSelectRowTopics;
	}

	public void setAfterSelectRowTopics(String afterSelectRowTopics) {
		this.afterSelectRowTopics = afterSelectRowTopics;
	}

	public void setBeforeEditTopics(String beforeEditTopics) {
		this.beforeEditTopics = beforeEditTopics;
	}

	public void setAfterEditTopics(String afterEditTopics) {
		this.afterEditTopics = afterEditTopics;
	}

	public void setBeforeSaveTopics(String beforeSaveTopics) {
		this.beforeSaveTopics = beforeSaveTopics;
	}

	public void setBeforeLoadTopics(String beforeLoadTopics) {
		this.beforeLoadTopics = beforeLoadTopics;
	}

	public void setBeforeInsertTopics(String beforeInsertTopics) {
		this.beforeInsertTopics = beforeInsertTopics;
	}

	public void setAfterInsertTopics(String afterInsertTopics) {
		this.afterInsertTopics = afterInsertTopics;
	}

	public void setBeforeUpdateTopics(String beforeUpdateTopics) {
		this.beforeUpdateTopics = beforeUpdateTopics;
	}

	public void setAfterUpdateTopics(String afterUpdateTopics) {
		this.afterUpdateTopics = afterUpdateTopics;
	}

	public void setBeforeDeleteTopics(String beforeDeleteTopics) {
		this.beforeDeleteTopics = beforeDeleteTopics;
	}

	public void setAfterDeleteTopics(String afterDeleteTopics) {
		this.afterDeleteTopics = afterDeleteTopics;
	}

	public void setOnUpdateRecordTopics(String onUpdateRecordTopics) {
		this.onUpdateRecordTopics = onUpdateRecordTopics;
	}

	public void setBeforeGotoPageTopics(String beforeGotoPageTopics) {
		this.beforeGotoPageTopics = beforeGotoPageTopics;
	}
	
	
}
